import 'package:dk_flutter_base/dk_ui.dart';
import 'package:dk_flutter_module_sale/phoenix/my_setting/resource/meSettingResource.dart';

class TitleWidget extends StatelessWidget {
  final bool isShowRedDot;
  final String title;
  final GestureTapCallback onTap;
  final Image rightIconImage;
  final hiddenBottomLine;
  TitleWidget({
    this.isShowRedDot:false,
    this.title:"",
    this.onTap,
    this.rightIconImage,
    this.hiddenBottomLine:false
  });

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap:onTap ,
      child: Container(
        color: Colors.white,
        child: Container(
          margin: const EdgeInsets.only(left: 15.0),
          padding: const EdgeInsets.fromLTRB(0, 15.0, 15.0, 15.0),
          constraints: BoxConstraints(
              maxHeight: double.infinity,
              minHeight: 48.0
          ),
          decoration:BoxDecoration(
              border: this.hiddenBottomLine ? null : Border(
                bottom: Divider.createBorderSide(context, color: Color(0xFFEBEEEF), width:0.5),
              )
            ),
          child: Row(
            crossAxisAlignment:CrossAxisAlignment.center,
            children: <Widget>[
              Text(
                title,
                style: TextStyle(
                  color: Color(0xFF333333),
                  fontSize: 15
                ),
              ),
              const Spacer(),
              Opacity(
                opacity: this.isShowRedDot ? 1 : 0,
                child: Padding(
                  padding: EdgeInsets.only(right: 6),
                  child: ClipOval(child: Container(
                    width: 8,
                    height: 8,
                    color: Color(0xFFFF5D6A),
                  )),
                ),
              ),
              Opacity(
                // 无点击事件时，隐藏箭头图标
                opacity: onTap == null ? 0 : 1,
                child: this.rightIconImage ??
                    Image.network(MESettingImage.rightImageURL,
                    width: 12,
                    height: 12,
                      fit: BoxFit.contain,
                    ),
              )
            ],
          ),
        ),
      ),
    );
  }
}

